package com.hjr.calculator;

import java.math.BigDecimal;

public class CalcCmd implements Cmd<BigDecimal> {

    private String op;

    private BigDecimal num1;

    private BigDecimal num2;

    private final CalcStrategyContext calcStrategyContext = CalcStrategyContext.getInstance();

    public CalcCmd(){}


    @Override
    public BigDecimal exec() {
        CalcStrategy strategy = this.calcStrategyContext.getByOp(op);
        return strategy.calc(num1, num2);
    }

    public void setOp(String op) {
        this.op = op;
    }

    public void setNum1(BigDecimal num1) {
        this.num1 = num1;
    }

    public void setNum2(BigDecimal num2) {
        this.num2 = num2;
    }

    public String getOp() {
        return op;
    }

    public BigDecimal getNum1() {
        return num1;
    }

    public BigDecimal getNum2() {
        return num2;
    }
}